import { Module } from '@nestjs/common';
import { JwtModule } from '@nestjs/jwt';
import { PassportModule } from '@nestjs/passport';
import { AuthController } from '../controllers/authority.controller';
import { AuthorityService } from '../services/authority.service';
import { jwtConfig } from '../config/jwtConfig ';

@Module({
  providers: [AuthorityService],
  controllers: [AuthController],
  imports: [
    PassportModule.register({ defaultStrategy: 'jwt' }),
    JwtModule.register({
      secret: jwtConfig.Secret, // 生成token的key
      signOptions: {
        expiresIn: jwtConfig.ExpireTime, // 有效时长
      },
    }),
  ],
  exports: [AuthorityService], // 注意这里不可少，表示对外暴露service引用
})
export class AuthorModule {}
